package com.neusoft.neumooc.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.neusoft.core.common.BaseService;
import com.neusoft.core.common.exception.ServiceException;
import com.neusoft.neumooc.dao.ContentTypeDAO;
import com.neusoft.neumooc.vo.ContentTypeVO;

@Service
@Transactional
public class ContentTypeServiceImpl extends BaseService implements ContentTypeService {

    @Autowired
    private ContentTypeDAO contentTypeDAO;
    
    @Override
    public List<ContentTypeVO> getAllContentTypes() throws ServiceException {
        try {
            return contentTypeDAO.getAllContentTypes();
        } catch (Exception e) {
            log.error("获取内容类型列表失败", e);
            throw new ServiceException("获取内容类型列表失败", e);
        }
    }

    @Override
    public ContentTypeVO getContentTypeById(String typeId) throws ServiceException {
        try {
            return contentTypeDAO.getContentTypeById(typeId);
        } catch (Exception e) {
            log.error("获取内容类型失败", e);
            throw new ServiceException("获取内容类型失败", e);
        }
    }

    @Override
    public boolean addContentType(ContentTypeVO contentType) throws ServiceException {
        try {
            return contentTypeDAO.addContentType(contentType);
        } catch (Exception e) {
            log.error("添加内容类型失败", e);
            throw new ServiceException("添加内容类型失败", e);
        }
    }

    @Override
    public boolean updateContentType(ContentTypeVO contentType) throws ServiceException {
        try {
            return contentTypeDAO.updateContentType(contentType);
        } catch (Exception e) {
            log.error("更新内容类型失败", e);
            throw new ServiceException("更新内容类型失败", e);
        }
    }

    @Override
    public boolean deleteContentType(String typeId) throws ServiceException {
        try {
            return contentTypeDAO.deleteContentType(typeId);
        } catch (Exception e) {
            log.error("删除内容类型失败", e);
            throw new ServiceException("删除内容类型失败", e);
        }
    }
} 